<template>
    <div class="header  header-index" @resize="resize" :class="{otherPageHeader:!isIndex}">
        <div class="head_box">
			<div class="logo">
			    <div class="logo-img" @click="()=>{this.$router.push('/')}">
			        <img :src="isIndex?require('@/assets/img/logo-header2.png'):require('@/assets/img/logo-header.png')"/>
			    </div>
			</div>
			<div class="right">
			    <div class="right-phone" id="headerPhone">
			        免费电话：010-1646546516
			    </div>
			    <!-- <div class="logo-icon">
			        <div class="logo-icon-item" @click="$router.push({name:'SearchResult'})">
			            <svg class="icon" aria-hidden="true" style="cursor: pointer">
			                <use xlink:href="#icon-sousuo"></use>
			            </svg>
			        </div>
			        <div class="logo-icon-item" @click="showSecondMenu=true">
			            <svg class="icon" aria-hidden="true" style="cursor: pointer">
			                <use xlink:href="#icon-caidan"></use>
			            </svg>
			        </div>
			    </div> -->
			</div>
		</div>
        <van-popup v-model:show="showSecondMenu" position="right" :style="{ height: '100%'}" @open="openRightMenu">
            <div class="right-menu-logo">
                <div class="logo-text">
                    <img src="~@/assets/img/index-name.png" alt=""/>
                </div>
            </div>
            <div class="right-menu-list">
                <div class="menu-item animate__animated" :class="{animate__fadeInRight:showMenuAni[0],active:menu.Home}"
                     v-show="showMenuAni[0]"
                     @click="jumpMenu('/',$event)">{{ $t('menu.home') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[1],active:menu.About}" v-show="showMenuAni[1]"
                     @click="jumpMenu('/about',$event)">{{ $t('menu.about') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[2],active:menu.BusinessArea}" v-show="showMenuAni[2]"
                     @click="jumpMenu('/businessArea',$event)">{{ $t('menu.area') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[3],active:menu.ExpertTeam}" v-show="showMenuAni[3]"
                     @click="jumpMenu('/expertTeam',$event)">{{ $t('menu.team') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[4],active:menu.NewsCenter}" v-show="showMenuAni[4]"
                     @click="jumpMenu('/newsCenter',$event)">{{ $t('menu.news') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[5],active:menu.LegalWorks}" v-show="showMenuAni[5]"
                     @click="jumpMenu('/legalWorks',$event)">{{ $t('menu.book') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[6],active:menu.ClassicCases}" v-show="showMenuAni[6]"
                     @click="jumpMenu('/classicCases',$event)">{{ $t('menu.case') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[7],active:menu.Recruitment}" v-show="showMenuAni[7]"
                     @click="jumpMenu('/recruitment',$event)">{{ $t('menu.joinUs') }}
                </div>
                <div class="menu-item animate__animated"
                     :class="{animate__fadeInRight:showMenuAni[8],active:menu.ContactUs}" v-show="showMenuAni[8]"
                     @click="jumpMenu('/contactUs',$event)">{{ $t('menu.contactUs') }}
                </div>
            </div>
        </van-popup>
    </div>
</template>

<script>
export default {
    data() {
        return {
            showSecondMenu: false,
            showMenuAni: [false, false, false, false, false, false, false, false, false],
            isPhone: false,
            menu: {
                Home: false,
                About: false,
                BusinessArea: false,
                ExpertTeam: false,
                NewsCenter: false,
                LegalWorks: false,
                AllDetails: false,
                ClassicCases: false,
                Recruitment: false,
                ContactUs: false,
                SearchResult: false,
            }
        }
    },
    props: ['showSearch', 'showMenuBtn', 'isIndex'],
    created() {
        window.addEventListener("resize", () => {

        })
        window.addEventListener("load", () => {

        })
    },
    mounted() {
        this.isPhone = screen.width <= 680;
        for (let x in this.menu) {
            this.menu[x] = false;
        }
        this.menu[this.$route.name] = true;
    },
    methods: {
        resize() {

        },
        jumpMenu(path, event) {
            //获取点击对象
            let el = event.currentTarget;
            this.$router.push(path)
        },
        openRightMenu() {
            for (let i = 0; i < this.showMenuAni.length; i++) {
                this.showMenuAni[i] = false;
            }
            window.rightMenuIntervalCount = 0
            if (window.rightMenuInterval) {
                clearInterval(window.rightMenuInterval);
            }
            window.rightMenuInterval = setInterval(() => {
                if (window.rightMenuIntervalCount < this.showMenuAni.length) {
                    this.showMenuAni[window.rightMenuIntervalCount] = true;
                    window.rightMenuIntervalCount++;
                } else {
                    clearInterval(window.rightMenuInterval);
                    window.rightMenuInterval = null;
                }
            }, 50)
        }
    }
}
</script>

<style lang="less">
#app {
    .otherPageHeader {
        box-shadow: none;
        background: none;
        position: relative;

        .right-phone {
            display: none;
        }

        .logo-icon-item {
            z-index: 19950225;
            .icon {
                color: #FFFFFF;
            }
        }
    }
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
	background: #ffffff;
    align-items: center;
	margin: 0 auto;
    height: 154px;
    z-index: 1995;
	.head_box{
		width: 1200px;
		height:100%;
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
    .logo {
        display: flex;
        height: 64px;
        .logo-img {
            cursor: pointer;

            img {
                height: 64px;
            }

            margin-right: 30px;
            height: 64px;
        }

        .logo-text {
            padding-left: 30px;
            border-left: 1px solid #855949;

            img {
                height: 100%;
            }
        }
    }

    .right {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;

        .right-phone {
            border: 1px solid #855949;
            border-radius: 5px;
            color: #855949;
            padding: 17px 64px;
        }

        .logo-icon {
            display: flex;
            justify-content: space-between;
            width: 150px;
            padding-left: 50px;
        }

        .icon {
            color: #855949;
            height: 100%;
            width: 47%;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
        }
    }
}

.header-index {
    background: #FFFFFF;
}

.right-menu-logo {
    width: 80%;
    justify-content: space-between;
    margin: 20px auto;

    .logo-text {
        width: 100%;

        img {
            width: 100%;
        }
    }

}

.right-menu-list {
    width: 100%;
    margin-top: 50px;
    overflow: hidden;

    .menu-item {
        width: calc(100% - 40px);
        padding: 20px;
        border-bottom: 1px solid #000000;
        cursor: pointer;
        transition-property: background-color;
        transition-duration: 0.5s;
        transition-timing-function: ease-in-out;

    }

    .active {
        border-color: #993C1A;
        color: #993C1A;
    }

    .menu-item:hover {
        background: #993C1A;
        color: #FFFFFF;
    }
}

.van-popup--right {
    width: 20%;
}
</style>
<style lang="less">
@media screen and (min-width: 0px) and (max-width: 680px) {
    .van-popup--right {
        width: 40%;
    }

    .right-menu-list {
        margin-top: 20px;
    }
}
@media screen and (min-width:960px) and (max-width:1200px) {
    .header .head_box {
		width: 960px;
		height: 100%;
	}
}
@media screen and (min-width:720px) and (max-width:960px) {
    .header .head_box {
		width: 720px;
		height: 100%;
	}
}
</style>
